import { InjectionToken, DependencyContainer } from "tsyringe"
import type { Request as IRequest, Response as IResponse, NextFunction as INextFunction } from 'express'
import type { WebSocketServer, WebSocket } from 'ws'
import type { Server } from 'http'
import type { Express } from 'express'
import type { Adapter } from 'casbin'
import { Store } from "express-session"
export const CasbinAdapter: InjectionToken<Adapter> = `CasbinAdapter`
export const Request: InjectionToken<IRequest> = `Request`
export const Response: InjectionToken<IResponse> = `Response`
export const NextFunction: InjectionToken<INextFunction> = `NextFunction`
export const ROOT: InjectionToken<string> = `ROOT`
export const Injector: InjectionToken<DependencyContainer> = `Injector`
export const ENV: InjectionToken<any> = `ENV`
export const Body: InjectionToken<any> = `Body`
export const Query: InjectionToken<any> = `Query`
export const Headers: InjectionToken<any> = `Headers`
export const ClearCache: InjectionToken<any> = `ClearCache`
export const USER_STORE: InjectionToken<Store> = `USER_STORE`
export const SERVER_CALL: InjectionToken<boolean> = `SERVER_CALL`

/**
 * 全局Token
 */
export const EXPRESS: InjectionToken<Express> = `EXPRESS`
export const SERVER: InjectionToken<Server> = `SERVER`
export const WEBSOCKETSERVER: InjectionToken<WebSocketServer> = `WEBSOCKETSERVER`

export interface IRequire {
    (id: string, paths: string[]): any;
}
export const REQUIRE: InjectionToken<IRequire> = `REQUIRE`

export const WEBSOCKETS: InjectionToken<Map<string, WebSocket>> = `WEBSOCKETS`
export const WEBSOCKET: InjectionToken<WebSocket> = `WEBSOCKET`

export interface IWechatConfig {
    (): Promise<{ appid: string, appsecret: string }>
}
export const WechatConfig: InjectionToken<IWechatConfig> = `WechatConfig`

export {
    IRequest,
    IResponse,
    INextFunction,
    DependencyContainer
}
